package excel;

import io.swagger.annotations.ApiOperation;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author zhanglinfeng
 * @date create in 2024/6/11 15:34
 */
@RestController
public class TemplateController {

    @ApiOperation("模版下载(不生成文件)")
    @GetMapping("/v1/template/download")
    public void downloadTemplate(HttpServletResponse response) throws IOException {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("template/test.xlsm");
        XSSFWorkbook wb = new XSSFWorkbook(inputStream);
        ExcelUtil.writeResponseStream(response, wb, "test.xlsm");
    }

}
